/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package vn.com.fis.portal.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import vn.com.fis.portal.model.VideoUserVideoGroupEntry;
import vn.com.fis.portal.model.VideoUserVideoGroupEntryModel;
import vn.com.fis.portal.model.VideoUserVideoGroupEntrySoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.List;

/**
 * The base model implementation for the VideoUserVideoGroupEntry service. Represents a row in the &quot;TBL_VIDEO_USER_VIDEO_GROUP&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link vn.com.fis.portal.model.VideoUserVideoGroupEntryModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link VideoUserVideoGroupEntryImpl}.
 * </p>
 *
 * @author loind
 * @see VideoUserVideoGroupEntryImpl
 * @see vn.com.fis.portal.model.VideoUserVideoGroupEntry
 * @see vn.com.fis.portal.model.VideoUserVideoGroupEntryModel
 * @generated
 */
@JSON(strict = true)
public class VideoUserVideoGroupEntryModelImpl extends BaseModelImpl<VideoUserVideoGroupEntry>
	implements VideoUserVideoGroupEntryModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a video user video group entry model instance should use the {@link vn.com.fis.portal.model.VideoUserVideoGroupEntry} interface instead.
	 */
	public static final String TABLE_NAME = "TBL_VIDEO_USER_VIDEO_GROUP";
	public static final Object[][] TABLE_COLUMNS = {
			{ "videoUserVideoGroupID", Types.BIGINT },
			{ "videoUserId", Types.BIGINT },
			{ "videoGroupId", Types.BIGINT }
		};
	public static final String TABLE_SQL_CREATE = "create table TBL_VIDEO_USER_VIDEO_GROUP (videoUserVideoGroupID LONG not null primary key,videoUserId LONG,videoGroupId LONG)";
	public static final String TABLE_SQL_DROP = "drop table TBL_VIDEO_USER_VIDEO_GROUP";
	public static final String ORDER_BY_JPQL = " ORDER BY videoUserVideoGroupEntry.videoUserVideoGroupID ASC";
	public static final String ORDER_BY_SQL = " ORDER BY TBL_VIDEO_USER_VIDEO_GROUP.videoUserVideoGroupID ASC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.vn.com.fis.portal.model.VideoUserVideoGroupEntry"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.vn.com.fis.portal.model.VideoUserVideoGroupEntry"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.vn.com.fis.portal.model.VideoUserVideoGroupEntry"),
			true);
	public static long VIDEOGROUPID_COLUMN_BITMASK = 1L;
	public static long VIDEOUSERID_COLUMN_BITMASK = 2L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static VideoUserVideoGroupEntry toModel(
		VideoUserVideoGroupEntrySoap soapModel) {
		VideoUserVideoGroupEntry model = new VideoUserVideoGroupEntryImpl();

		model.setVideoUserVideoGroupID(soapModel.getVideoUserVideoGroupID());
		model.setVideoUserId(soapModel.getVideoUserId());
		model.setVideoGroupId(soapModel.getVideoGroupId());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<VideoUserVideoGroupEntry> toModels(
		VideoUserVideoGroupEntrySoap[] soapModels) {
		List<VideoUserVideoGroupEntry> models = new ArrayList<VideoUserVideoGroupEntry>(soapModels.length);

		for (VideoUserVideoGroupEntrySoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.vn.com.fis.portal.model.VideoUserVideoGroupEntry"));

	public VideoUserVideoGroupEntryModelImpl() {
	}

	public long getPrimaryKey() {
		return _videoUserVideoGroupID;
	}

	public void setPrimaryKey(long primaryKey) {
		setVideoUserVideoGroupID(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_videoUserVideoGroupID);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return VideoUserVideoGroupEntry.class;
	}

	public String getModelClassName() {
		return VideoUserVideoGroupEntry.class.getName();
	}

	@JSON
	public long getVideoUserVideoGroupID() {
		return _videoUserVideoGroupID;
	}

	public void setVideoUserVideoGroupID(long videoUserVideoGroupID) {
		_columnBitmask = -1L;

		_videoUserVideoGroupID = videoUserVideoGroupID;
	}

	@JSON
	public long getVideoUserId() {
		return _videoUserId;
	}

	public void setVideoUserId(long videoUserId) {
		_columnBitmask |= VIDEOUSERID_COLUMN_BITMASK;

		if (!_setOriginalVideoUserId) {
			_setOriginalVideoUserId = true;

			_originalVideoUserId = _videoUserId;
		}

		_videoUserId = videoUserId;
	}

	public String getVideoUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getVideoUserId(), "uuid", _videoUserUuid);
	}

	public void setVideoUserUuid(String videoUserUuid) {
		_videoUserUuid = videoUserUuid;
	}

	public long getOriginalVideoUserId() {
		return _originalVideoUserId;
	}

	@JSON
	public long getVideoGroupId() {
		return _videoGroupId;
	}

	public void setVideoGroupId(long videoGroupId) {
		_columnBitmask |= VIDEOGROUPID_COLUMN_BITMASK;

		if (!_setOriginalVideoGroupId) {
			_setOriginalVideoGroupId = true;

			_originalVideoGroupId = _videoGroupId;
		}

		_videoGroupId = videoGroupId;
	}

	public long getOriginalVideoGroupId() {
		return _originalVideoGroupId;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public VideoUserVideoGroupEntry toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (VideoUserVideoGroupEntry)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
					VideoUserVideoGroupEntry.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	@Override
	public Object clone() {
		VideoUserVideoGroupEntryImpl videoUserVideoGroupEntryImpl = new VideoUserVideoGroupEntryImpl();

		videoUserVideoGroupEntryImpl.setVideoUserVideoGroupID(getVideoUserVideoGroupID());
		videoUserVideoGroupEntryImpl.setVideoUserId(getVideoUserId());
		videoUserVideoGroupEntryImpl.setVideoGroupId(getVideoGroupId());

		videoUserVideoGroupEntryImpl.resetOriginalValues();

		return videoUserVideoGroupEntryImpl;
	}

	public int compareTo(VideoUserVideoGroupEntry videoUserVideoGroupEntry) {
		int value = 0;

		if (getVideoUserVideoGroupID() < videoUserVideoGroupEntry.getVideoUserVideoGroupID()) {
			value = -1;
		}
		else if (getVideoUserVideoGroupID() > videoUserVideoGroupEntry.getVideoUserVideoGroupID()) {
			value = 1;
		}
		else {
			value = 0;
		}

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		VideoUserVideoGroupEntry videoUserVideoGroupEntry = null;

		try {
			videoUserVideoGroupEntry = (VideoUserVideoGroupEntry)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = videoUserVideoGroupEntry.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		VideoUserVideoGroupEntryModelImpl videoUserVideoGroupEntryModelImpl = this;

		videoUserVideoGroupEntryModelImpl._originalVideoUserId = videoUserVideoGroupEntryModelImpl._videoUserId;

		videoUserVideoGroupEntryModelImpl._setOriginalVideoUserId = false;

		videoUserVideoGroupEntryModelImpl._originalVideoGroupId = videoUserVideoGroupEntryModelImpl._videoGroupId;

		videoUserVideoGroupEntryModelImpl._setOriginalVideoGroupId = false;

		videoUserVideoGroupEntryModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<VideoUserVideoGroupEntry> toCacheModel() {
		VideoUserVideoGroupEntryCacheModel videoUserVideoGroupEntryCacheModel = new VideoUserVideoGroupEntryCacheModel();

		videoUserVideoGroupEntryCacheModel.videoUserVideoGroupID = getVideoUserVideoGroupID();

		videoUserVideoGroupEntryCacheModel.videoUserId = getVideoUserId();

		videoUserVideoGroupEntryCacheModel.videoGroupId = getVideoGroupId();

		return videoUserVideoGroupEntryCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(7);

		sb.append("{videoUserVideoGroupID=");
		sb.append(getVideoUserVideoGroupID());
		sb.append(", videoUserId=");
		sb.append(getVideoUserId());
		sb.append(", videoGroupId=");
		sb.append(getVideoGroupId());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(13);

		sb.append("<model><model-name>");
		sb.append("vn.com.fis.portal.model.VideoUserVideoGroupEntry");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>videoUserVideoGroupID</column-name><column-value><![CDATA[");
		sb.append(getVideoUserVideoGroupID());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>videoUserId</column-name><column-value><![CDATA[");
		sb.append(getVideoUserId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>videoGroupId</column-name><column-value><![CDATA[");
		sb.append(getVideoGroupId());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = VideoUserVideoGroupEntry.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			VideoUserVideoGroupEntry.class
		};
	private long _videoUserVideoGroupID;
	private long _videoUserId;
	private String _videoUserUuid;
	private long _originalVideoUserId;
	private boolean _setOriginalVideoUserId;
	private long _videoGroupId;
	private long _originalVideoGroupId;
	private boolean _setOriginalVideoGroupId;
	private transient ExpandoBridge _expandoBridge;
	private long _columnBitmask;
	private VideoUserVideoGroupEntry _escapedModelProxy;
}